import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
ans = 0
for i in range(1, n + 1):
for j in range(i, n + 1):
k = i ^ j
if j <= k <= n and i + j > k:
ans += 1
print(ans)
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int long long
int komi = 0;
int check( vector<int> arr){
if( arr[0] + arr[1] > arr[2])
return 1;
return 0;
}
void solve(){
int n; cin >> n;
set< vector<int> > st;
for( int i = 1; i <= n; ++i){
for( int j = i; j<=n; ++j){
if( (i^j) > n) continue;
vector<int> arr = {i,j, i^j};
sort( all(arr));
if( check(arr)){
st.insert(arr);
}
}
}
cout << st.size();
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test = 1;
// cin >> test;
while( test--){
solve();
cout << "\n";
}
return 0;
}
961A - Tetris | 1635B - Avoid Local Maximums |
20A - BerOS file system | 1637A - Sorting Parts |
509A - Maximum in Table | 1647C - Madoka and Childish Pranks |
689B - Mike and Shortcuts | 379B - New Year Present |
1498A - GCD Sum | 1277C - As Simple as One and Two |
1301A - Three Strings | 460A - Vasya and Socks |
1624C - Division by Two and Permutation | 1288A - Deadline |
1617A - Forbidden Subsequence | 914A - Perfect Squares |
873D - Merge Sort | 1251A - Broken Keyboard |
463B - Caisa and Pylons | 584A - Olesya and Rodion |
799A - Carrot Cakes | 1569B - Chess Tournament |
1047B - Cover Points | 1381B - Unmerge |
1256A - Payment Without Change | 908B - New Year and Buggy Bot |
979A - Pizza Pizza Pizza | 731A - Night at the Museum |
742A - Arpa’s hard exam and Mehrdad’s naive cheat | 1492A - Three swimmers |